﻿<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href=" /favicon.ico" />
    <title>校园支付 - 安全设置</title>
    <link href="css/main.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/dialog.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.1.6.2_mini.js" type="text/javascript"></script>
    <script src="js/dialog.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="js/service.js" type="text/javascript"></script>
    <script type="text/javascript">
        var defaultValues = ['<s:property value="mobile"/>', '<s:property value="email"/>', '原密码', '新密码', '再次输入密码'];

        $(function () {
            //获取当前登录用户信息
            //GetCurrentUserBaseInfo();

            //文本框输入获得焦点切换
            $('input:[type=text]').each(function (i) {
                var defaultValue = defaultValues[i];
                $(this).val(defaultValue).bind({
                    'focus': function () {
                        if ($(this).attr('name').toLowerCase().indexOf('pass') < 0) {
                            var tmpVal = $(this).val();
                            if (!tmpVal || tmpVal == defaultValue) {
                                $(this).val('').addClass('act');
                            }
                        } else {
                            var _this = $(this);
                            var _oldName = $(this).attr('name').split('_')[1];
                            var _newName = 'pwd_' + _oldName;

                            var realPass = $('<input />')
                            .attr({ 'class': 'act', 'name': _newName, 'id': _newName, 'type': 'password', 'maxlength': 16 })
                            .val('')
                            .blur(function () {
                                if (!$(this).val()) {
                                    $(this).remove();
                                    _this.show();
                                }
                            });
                            $(this).hide().before(realPass);
                            realPass[0].focus();
                        }
                    },
                    'blur': function () {
                        var tmpVal = $(this).val();
                        if (!tmpVal || tmpVal == defaultValue) {
                            $(this).val(defaultValue).removeClass('act');
                        }
                    }
                });
            });

            //获取当前用户的安全设置信息
            //GetUserSafeOptions();

            $('#btn_SubmitMobile').click(function () {
                var mobileNum = $('#txt_Mobile').val().Trim();
                var regex = /^[1][34568][0-9]{9}$/;
                if (!regex.test(mobileNum)) {
                    Alert('请正确输入手机号码！');
                    return;
                }
                $('#type').val('mobile');
                $('#mobile').val($('#txt_Mobile').val());
                $('#safeForm').submit();
            });

            $('#btn_SubmitEMail').click(function () {
                var email = $('#txt_EMail').val().Trim();
                var regex = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
                if (!regex.test(email)) {
                    Alert('请正确输入电子邮件地址！');
                    return;
                }
                $('#type').val('email');
                $('#email').val($('#txt_EMail').val());
                $('#safeForm').submit();
            });
            
            $('#btn_SubmitPassword').click(function () {
                $('#type').val('pass');
                $('#oldPass').val($('#pwd_OldPass').val());
                $('#newPass').val($('#pwd_NewPass').val());
                $('#newPassAgain').val($('#pwd_NewPassAgain').val());
                $('#safeForm').submit();
			});            
            
        });

        var ChangeMobile = function (mobile, info) {
            $('#txt_Mobile').hide();
            $('#txt_Mobile').next().html(mobile).show();
            $('#sp_safeMobileInfo').html('&nbsp;');
            var changeBtn = $('<input type="button" name="btn_ChangeMobile" id="btn_ChangeMobile" value="修改" />').click(
                function () {
                    $('#txt_Mobile').val('').show().focus();
                    $('#txt_Mobile').next().html('').hide();
                    $('#sp_safeMobileInfo').html(info);
                    $(this).remove();
                    $('#btn_SubmitMobile').show();
                }
            );
            $('#btn_SubmitMobile').after(changeBtn).hide();
        };

        var ChangeEmail = function (email, info) {
            $('#txt_EMail').hide();
            $('#txt_EMail').next().html(email).show();
            $('#sp_safeEmailInfo').html('&nbsp;');
            var changeBtn = $('<input type="button" name="btn_ChangeEmail" id="btn_ChangeEmail" value="修改" />').click(
                function () {
                    $('#txt_EMail').val('').show().focus();
                    $('#txt_EMail').next().html('').hide();
                    $('#sp_safeEmailInfo').html(info);
                    $(this).remove();
                    $('#btn_SubmitEMail').show();
                }
            );
            $('#btn_SubmitEMail').after(changeBtn).hide();
        };    
    </script>
</head>
<body>
    <!--头部区域-->
    <div id="header">
        <!-- <a href="help.html" target="_blank" title="帮助"></a> -->
        <a href="quit.action" title="退出"></a>
    </div>
    <!--用户信息区域-->
    <div id="userBlock">
        <!--用户头像-->
        <div class="headIconBox">
            <img id="img_UserIcon" src="<s:property value="userIcon"/>" alt="用户头像" />
            <p title="点击更改头像"></p>
        </div>
        <!--用户个人账户信息-->
        <div class="baseInfoBox">
            <ul>
                <li id="li_UserName"><s:property value="hello"/></li>
                <li id="li_UserNo">学  号：<s:property value="userNo"/></li>
                <li class="last" id="li_LastLoginTime">最后一次登录时间：<s:property value="loginTime"/></li>
            </ul>
        </div> 
    </div>

    <div class="block">
        <div class="mima">
            <ul class="ulmima">
                <li>
                    <span class="sp01">手机验证</span>
                    <span class="sp04">
                        <input type="text" name="txt_Mobile" id="txt_Mobile" value="填写手机号码增强安全级别" maxlength="11" />
                        <label></label>
                    </span>
                    <span class="sp05" id="sp_safeMobileInfo">有助于及时通报帐号异常，也有助于找回用户资料、密码</span>
                    <span class="sp06">
                        <input type="button" name="btn_SubmitMobile" id="btn_SubmitMobile" value="确定" title="点击设置手机验证" />
                    </span>
                </li>
                <li>
                    <span class="sp02">邮箱验证</span>
                    <span class="sp04">
                        <input type="text" name="txt_EMail" id="txt_EMail" value="填写邮箱地址增强安全级别" maxlength="100" />
                        <label></label>
                    </span>
                    <span class="sp05" id="sp_safeEmailInfo">有助于及时通报帐号异常，也有助于找回用户资料、密码</span>
                    <span class="sp06">
                        <input type="button" name="btn_SubmitEMail" id="btn_SubmitEMail" value="确定" title="点击设置电子邮件验证" />
                    </span>
                </li>
                <li>
                    <span class="sp03">修改密码</span>
                    <span class="sp05">建议你定期修改密码，密码为八位数，可以是数字字母……</span>
                </li>
                <li class="li01">
                    <input type="text" name="txt_OldPass" id="txt_OldPass" value="原密码" maxlength="16" />
                </li>
                <li class="li01">
                    <input type="text" name="txt_NewPass" id="txt_NewPass" value="新密码" maxlength="16" />
                </li>
                <li class="li01">
                    <input type="text" name="txt_NewPassAgain" id="txt_NewPassAgain" value="再次输入密码" maxlength="16" />
                </li>
                <li class="li01">
                    <span class="sp06">
                        <input type="button" name="btn_SubmitPassword" id="btn_SubmitPassword" value="修改" title="点击修改密码" />
                    </span>
                </li>
            </ul>
        </div>
    </div>
    
    <form id="safeForm" action="safe!update.action" method="post">
    	<input id="type" name="type" type="hidden" />
    	<input id="mobile" name="mobile" type="hidden" />
    	<input id="email" name="email" type="hidden" />
    	<input id="oldPass" name="oldPass" type="hidden" />
    	<input id="newPass" name="newPass" type="hidden" />
    	<input id="newPassAgain" name="newPassAgain" type="hidden" />
    </form>    

    <!--底部版权信息-->
    <!--<div id="footer">
        底部版权信息
    </div>-->
    <script type="text/javascript" src="js/footer.js"></script>
</body>
</html>